package com.bjsy.controller;


import com.bjsy.pojo.Category;
import com.bjsy.service.CategoryService;
import com.bjsy.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 作者
 * @since 2022-01-19
 */
@RestController
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping
    public Result getAllCategory() {
        List<Category> categoryList = categoryService.list();
        if (!CollectionUtils.isEmpty(categoryList)) {
            return Result.success(categoryList);
        }
        return Result.fail(10005, "查询分类失败");
    }

}

